package io.sdl.controller;


import io.sdl.common.sys.dto.SdlInstitutionDTO;
import io.sdl.common.sys.dto.SdlInstitutionPicDTO;
import io.sdl.common.sys.dto.SdlInstitutionQaqDTO;
import io.sdl.common.sys.service.SdlDoctorsService;
import io.sdl.common.sys.service.SdlInstitutionPicService;
import io.sdl.common.sys.service.SdlInstitutionQaqService;
import io.sdl.common.sys.service.SdlInstitutionService;
import io.sdl.common.sys.vo.SdlInstitutionDetailVo;
import io.sdl.common.utils.ConvertUtils;
import io.sdl.common.utils.Query;
import io.sdl.common.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class ApiSdlInstitutionPicController {

    @Autowired
    private SdlInstitutionPicService sdlInstitutionPicService;

    @Autowired
    private SdlInstitutionService sdlInstitutionService;

    @Autowired
    private SdlDoctorsService sdlDoctorsService;
    @Autowired
    private SdlInstitutionQaqService sdlInstitutionQaqService;

    @GetMapping("find/pic/{institutionId}")
    @Operation(summary = "获取机构相关信息")
    public Result findInstitutionPic(@PathVariable("institutionId") Long institutionId) {
        SdlInstitutionDTO sdlInstitutionDTO = sdlInstitutionService.getbyId(institutionId);
        SdlInstitutionDetailVo sdlInstitutionDetailVo = ConvertUtils.sourceToTarget(sdlInstitutionDTO, SdlInstitutionDetailVo.class);

        List<SdlInstitutionPicDTO> picList = sdlInstitutionPicService.getPicList(institutionId);
        Map<String, Object> map = new HashMap<>();
        //查询机构相关证书
        List<SdlInstitutionQaqDTO> qaqPicList = sdlInstitutionQaqService.getQaqListByInstitutionId(institutionId);
        sdlInstitutionDetailVo.setCertificateList(qaqPicList);

        sdlInstitutionDetailVo.setSdlInstitutionPicList(picList);
        return new Result().ok(sdlInstitutionDetailVo);
    }


    @PostMapping("save/pic")
    @Operation(summary = "获取机构相关图片信息")
    public Result saveInstitutionPic(@RequestBody SdlInstitutionPicDTO sdlInstitutionPicDto) {

        return new Result();
    }

}
